<@master template="master/master-loan" title="归档资料配置">
       <div class="detailsBox detaiTab">
          <h3 class="mt20"><i class="jtIco"></i> 归档资料配置</h3>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
                	<tr>
                    	<td align="right" class="bg" width="15%">归档银行类型:</td>
                      	<td width="35%">${basic.customerName}
                      	<@select id="bankTypes" dataSouceType="BANK_TYPE_FILED" checked="checked" id="bank_type" class="tabInp" name="bankTypeId" value="${vo.bankTypeId}" onchange="change()"/></td>
                        <td align="right" class="bg" width="15%">归档资料类型:</td>
                        <td>${basic.customerNamePinyin}
 						<@select dataSouceType="FORM_TYPE_FILED" class="tabInp" id="form_type" name="bankLoan" value="${vo.bankLoan}" onchange="change()"/></td>
                        </td>
                    </tr>
                 </table>
			
        </div>
        
         <div class="dataBable mt20" style="border-right:1px solid #e1e1e1; border-left:1px solid #e1e1e1">
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="b_t_e5" id="dataTables" style="text-align: center;"  >
                   	<thead>
                   		<tr>
							<th>表单名称</th>
							<th>是否添加</th>
							<th>是否必填</th>
							<th>最小份数</th>
							<th>最大份数</th>
						</tr>
                   	</thead>
                    <tbody>
						<#list findAllFiles  as file>
							<tr>						
	                            <td align="right" class="bg " width="15%">${file.filedName}</td>
	                            <td style="text-align: center;"><input type="checkbox" /></td>
	                            <td style="text-align: center;"><input type="checkbox"  /></td>
	                            <td style="text-align: center;"><input onkeyup='this.value=this.value.replace(/\D/gi,"")' style="width: 30px;text-align:center;" type="text" /></td>
	                            <td style="text-align: center;"><input onkeyup='this.value=this.value.replace(/\D/gi,"")' style="width: 30px;text-align:center;" type="text" /></td>
	                        </tr>
						</#list>	
										
					
                    </tbody>
                </table> 
            </div> 		
      <div class=" mtb20 tac"><a href="#" onclick="save()" class="btn_auto_30 btn_blue">保 存</a></div>

    
<script>

	function change() {
		var bank_code = $("#bank_type").val();
		var form_code = $("#form_type").val();
		
		if (bank_code != "" && form_code != null && form_code != "" && form_code != null) {
		
			var skipUrl = "startDeploy?bankTypeId=" + bank_code + "&fileTypeId=" + form_code;
			skipUrl = skipUrl;
	    	$.ajax({
	    			url:skipUrl,
	    			type : 'get',
	    			success:function(result){
						if(result){
							$('#dataTables').html(result);
							$(".isAdd").each(function(index) {
								if ($(this).attr("checked") != "checked") {
									$(this).parent().next().children(":first").attr("disabled","disabled");
									$(this).parent().next().next().children(":first").attr("disabled","disabled");
									$(this).parent().next().next().next().children(":first").attr("disabled","disabled");
								}
							})
						}
	    			}
	    		});
		}
	}
	function save() {
		var bank_code = $("#bank_type").val();
		var form_code = $("#form_type").val();
		var params = bank_code + ";" + form_code + "/";
		var flag = 0;
		 var name ;
		if (bank_code =="") {
			alert("请选择归档银行类型")
		} else if (form_code =="") {
			alert("请选择归档资料类型")
		} else {
			$(".isAdd").each(function() {
			   
			    var check = $(this).attr("checked");
			    if (check == "checked") {
			    	var filedId = $(this).parent().prev().val();
			    	var isMust = $(this).parent().next().children(":first").attr("checked");
			    	var repuired ;
			    	if (isMust == "checked") {
			    		repuired = 1;
			    	} else {
			    		repuired = 0;
			    	}
			    	var min = $(this).parent().next().next().children(":first").val();
			    	var max = $(this).parent().next().next().next().children(":first").val();
			    	if (min == "" || min == null) {
			    		name = $(this).parent().prev().prev().html();
			    		flag = 1;
			    		return;
			    	} else if (max == "" || max == null) {
			    		name = $(this).parent().prev().prev().html();
			    		flag = 2;
			    		return;
			    	} else if (parseInt(max) < parseInt(min)) {
			    		name = $(this).parent().prev().prev().html();
			    		flag = 3;
			    		return;
			    	}
			    	params = params + filedId + "," + repuired + "," + min + "," +max + ";"
			    }
			});
			if (flag == 0) {
				var newUrl = "saveDeploy?files=" + params;
				$.ajax({
		    		url:newUrl,
		    		type : 'get',
		    		success:function(result){
						if(result){
							alert("保存成功")
							$("select").val("");
							window.location.reload();
						}
		    		}
		    	});
			} else if (flag == 1){
				
				alert("请输入'"+name+"'最小份数")
			} else if (flag == 2){
				alert("请输入'"+name+"'最大份数")
			} else if (flag == 3){
				alert("'" + name + "'" + "最小份数不得大于最大份数")
			}

		}

	}
	function boxclick(obj) {
			if ($(obj).attr("checked") == "checked")  {
				$(obj).attr("checked",null);
			} else {
				$(obj).attr("checked","checked");
			}
	}
	function boxclick1(obj) {
		boxclick(obj);
		if ($(obj).attr("checked") != "checked") {
			$(obj).parent().next().children(":first").attr("checked",null).attr("disabled","disabled");
			$(obj).parent().next().next().children(":first").attr("disabled","disabled").val("");
			$(obj).parent().next().next().next().children(":first").attr("disabled","disabled").val("");
		} else {
			$(obj).parent().next().children(":first").attr("disabled",null);
			$(obj).parent().next().next().children(":first").attr("disabled",null);
			$(obj).parent().next().next().next().children(":first").attr("disabled",null);
		}
	}
	
	
	
	
</script>


</@master>















